import re
import requests

url = 'http://www.heibanke.com/lesson/crawler_ex01/'

data = {'username': 'fuck', 'password': 0}

for i in range(31):
    print('正在猜密码', i, end=' ')
    data['password'] = i
    html = requests.post(url=url, data=data).text
    print(re.search(r'<h3>(.*?)</h3>', html).group(1))
    if '错误' not in html:
        break
